package daizuo.utils;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

/**
 * 缓存流来读取文件
 */
public class Readerinfo {

    public static ArrayList<String> read(String flag)    {
        ArrayList<String> strings = new ArrayList<>();
        try {
            //定义缓存对象
            BufferedReader br = null;
            br = new BufferedReader(new FileReader("e://" + flag + ".txt"));
            char[] chars = new char[1024];
            String line = null;
            while ((line = br.readLine()) != null) {
                strings.add(line + "");
            }
        }catch (Exception e){
        }
        return strings;
    }
    public static void main(String[] args) throws IOException {
        ArrayList<String> user = read("user");
       for(int i= 0;i<user.size();i++){
           System.out.println(user.get(i));
       }
    }
}
